package com.tdam2012.grupo04.data;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

public class ConectividadProvider extends ContentProvider{

	public static final Uri CONTENT_URI = Uri.parse("content://com.tdam2012.grupo04.data.conectividadprovider");
	
	private static ActividadesBD database;
	
	public static final String CONECTIVIDAD="Conectividad";
	public static final String GET="Select";
	public static final String LAST="Last";
	
	public static final String TABLE_CONECTIVIDAD="Conectividad";
	public static final String COL_FECHA="fecha";
	public static final String COL_CONEXION="con";
	public static final String COL_TIPO="tipo";
	public static final String COL_COD="cod";
	
	
	@Override
	public int delete(Uri uri, String selection, String[] selectionArgs) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getType(Uri uri) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Uri insert(Uri uri, ContentValues values) {
		database.insertConectividad(
				values.getAsString(COL_CONEXION),
				values.getAsString(COL_TIPO),
				values.getAsString(COL_FECHA));
		return null;
	}

	@Override
	public boolean onCreate() {
		database = new ActividadesBD(getContext());
		return false;
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		if (selection.equalsIgnoreCase(GET)) {
			return database.getConectividad();
		}else{
			return database.getLastConectividad();
		}
		
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		// TODO Auto-generated method stub
		return 0;
	}
	

}
